package com.djl.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.djl.ud.OrderDao;
import com.djl.user.Order;

public class OrderAllServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		PrintWriter out = response.getWriter();
		int id = 0;
		String name="";
		List<Order> list = new ArrayList<Order>();
		OrderDao od = new OrderDao();
		HttpSession session = request.getSession();
		if(!"".equals(Integer.parseInt(request.getParameter("orderId")))){
			id=Integer.parseInt(request.getParameter("orderId"));
		}
		if(request.getParameter("userName")!=null){
			name=request.getParameter("userName");
		}
		try {
			list=od.getUserAll(id,name);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		session.setAttribute("all", list);
		request.getRequestDispatcher("manage/order.jsp").forward(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			doGet(request, response);
	}

}
